package com.api;

import com.api.utils.CronUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@SpringBootApplication
@EnableAsync
@EnableTransactionManagement
@EnableScheduling
public class JavaApiApplication {

    public static void main(String[] args) {
        SpringApplication.run(JavaApiApplication.class, args);
        // 配置定时器并启动
        CronUtils.setMatchSecond(true);
        CronUtils.start();
        Runtime.getRuntime().addShutdownHook(new ExitHook());
    }

}


class ExitHook extends Thread {
    @Override
    public void run() {
        super.run();
        CronUtils.stop();
    }
}